GDK W32: Special handling for DELETE requests
authorРуслан Ижбулатов <lrn1986@gmail.com>
Sun, 26 Nov 2017 13:06:24 +0000 (13:06 +0000)
committerРуслан Ижбулатов <lrn1986@gmail.com>
Thu, 30 Nov 2017 04:17:27 +0000 (04:17 +0000)
1) Ensure that any DELETE requests from the target are sent to GDK, even if
   both the source and the target are in the same process and it
   is therefore possible to use a shortcut and call the handler directly
   in GTK layer
2) Ensure that target GDK doesn't do anything when GTK asks it to send
   a DELETE request, just report back immediately (the code up the stack
   does not check for successfullness when request is DELETE, so not giving
   it any data is OK).

The source code already synthesizes a DELETE request, so that side is
also taken care of.

https://bugzilla.gnome.org/show_bug.cgi?id=786509

gdk/win32/gdkselection-win32.c
gtk/gtkselection.c

index ce42d0d12dacc8b12b54a2e2a928846970cb0547..a9c8d77209e2591ff54e730162fdc4e3fd63e332 100644 (file)
@@ -2168,6 +2168,15 @@ convert_dnd_selection_to_target (GdkAtom    target,
   fmt.lindex = -1;
   fmt.tymed = TYMED_HGLOBAL;
 
+  /* We rely on GTK+ applications to synthesize the DELETE request
+   * for themselves, since they do know whether a DnD operation was a
+   * move and whether was successful. Therefore, we do not need to
+   * actually send anything here. Just report back without storing
+   * any data.
+   */
+  if (target == _gdk_win32_selection_atom (GDK_WIN32_ATOM_INDEX_DELETE))
+    return result;
+
   for (format = 0, with_transmute = 0; format == 0 && with_transmute < 2; with_transmute++)
     {
       for (i = 0;
index 73875a60a3327ef778d248f90e85fea232d57c6c..0c1f98d756667c9de0e7c6418654e7b65b4a81b0 100644 (file)
@@ -1124,6 +1124,15 @@ gtk_selection_convert (GtkWidget *widget,
   display = gtk_widget_get_display (widget);
   owner_window = gdk_selection_owner_get_for_display (display, selection);
   
+#ifdef GDK_WINDOWING_WIN32
+  /* Special handling for DELETE requests,
+   * make sure this goes down into GDK layer.
+   */
+  if (GDK_IS_WIN32_DISPLAY (display) &&
+      target == gdk_atom_intern_static_string ("DELETE"))
+    owner_window = NULL;
+#endif
+
   if (owner_window != NULL)
     {
       GtkWidget *owner_widget;